/**
 * Copyright � 2012 GestureSoft. ALL RIGHTS RESERVED.
 * This file contains proprietary and GestureSoft CONFIDENTIAL Information.
 * Use, disclosure or reproduction is prohibited.
 * 
 * @fileName TestParser.as
 * @creationDate Aug 8, 2012
 * @author 
 * @version 1.0
 */
package com.gesturesoft.imultimax.model.utility
{
	
	import com.gesturesoft.imultimax.model.vo.CurrencyVO;
	import com.gesturesoft.imultimax.model.vo.SettingsVO;
	
	import mx.collections.ArrayCollection;

	public class XMLUtilityParser
	{
		
		public function parseCurrencyCodes(val:String):ArrayCollection
		{
			
			var xml:XML = new XML(val);
			var arr:ArrayCollection = new ArrayCollection();
			for each(var item:XML in xml.enumeration)
			{
				
				var obj:CurrencyVO = new CurrencyVO();
				obj.label = item.@value.toString();
				obj.country = item.annotation.documentation.toString();
				
				arr.addItem(obj);
				
			}
			
			return arr;
			
		}
		
		public function parseAuthSettings(val:String):ArrayCollection
		{
			
			var xml:XML = new XML(val);
			var arr:ArrayCollection = new ArrayCollection();
			for each(var item:XML in xml.view)
			{
				
				var obj:SettingsVO = new SettingsVO();
				obj.property = item.@name.toString();
				obj.primary = (item.primary.toString() == 'yes')?true:false;
				obj.secondary = (item.secondary.toString() == 'yes')?true:false;
				
				arr.addItem(obj);
				
			}
			
			return arr;
			
		}
		
		public function parseAPISetings(val:String):ArrayCollection
		{
			
			var xml:XML = new XML(val);
			var arr:ArrayCollection = new ArrayCollection();
			for each(var item:XML in xml..api)
			{
				
				var obj:Object = new Object();
				obj.name = item.@name.toString();
				obj.email = item.@emailRequired.toString();
				obj.required = item.toString();
				
				arr.addItem(obj);
				
			}
			
			return arr;
			
		}
		
	}
	
}